<?php
/**
 * 老师会员中心 基础类
 * @author      HJC <hujianchuang@haowj.com>
 * @update      2014.07.06
 * @since       Version 1.0
 * 
 */
class BaseAction extends  Action
{
    var $userInfo = '';
    public function __construct()
    {
        parent::__construct();
        $nowurl =  urlencode(get_url());
        
        //判断登录状态
        if(!cookie('haowj_ustat'))  redirect(C('WWWURL').'/userlogin/index.htm?fromurl='.$nowurl);
        $haowj_ustat = json_decode(MAGIC_QUOTES_GPC?stripslashes(cookie('haowj_ustat')):cookie('haowj_ustat'),true);
        $this->userInfo = D('Teacher')->checkLogin($haowj_ustat);
        if(!$this->userInfo) $this->error('ERROR DATA!');
        $this->assign('userInfo',$this->userInfo);
        $this->assign('module_name',MODULE_NAME);
        $course_types = explode(",", $this->userInfo["course_types"]);
        $this->assign('course_types',$course_types);
        //赋值三要素
        $this->assSeo();
    }
    //空操作
    public function _empty()
    {
        die('错误了哦！');
    }
    
    
    //title 三要素处理
    public  function assSeo($title='',$keywords='',$description='')
    {
        if($title=='') $title = C('SEOTITLE'); 
        if($keywords=='') $keywords = C('SEOKEYWORDS'); 
        if($description=='') $description = C('SEODESCRIPTION'); 
        $seo['title']       = $title;
        $seo['keywords']    = $keywords;
        $seo['description'] = $description;
        $this->assign('seo',$seo);
    }
    //退出登录
    public function loginExit()
    {
        $_SESSION["_user_login_haowaijiao"] = "";
        setcookie('haowj_ustat',"",time() - 86400,'/','.haowj.com');
        $this->ajaxReturn('','成功！',1);
    }
}